package com.weitu.threeSimultaneities.safe.service.impl;

import com.weitu.threeSimultaneities.safe.entity.Safe;
import com.weitu.threeSimultaneities.safe.mapper.SafeMapper;
import com.weitu.threeSimultaneities.safe.service.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class SafeServiceImpl implements SafeService {
    @Autowired
    private SafeMapper safeMapper;
    @Autowired//可研阶段
    private SafeFSDService safeFSDService;
    @Autowired//基础设计阶段
    private SafeDesignService safeDesignService;
    @Autowired//试运行阶段
    private SafeCommissioningService safeCommissioningService;
    @Autowired//验收阶段
    private SafeAcceptanceService safeAcceptanceService;
    private static final Logger logger = LoggerFactory.getLogger(SafeServiceImpl.class);
    @Override
    public Safe selectByPrimaryKey(String id) {
        return this.safeMapper.selectByPrimaryKey(id);
    }
    @Override
    public int deleteByPrimaryKey(String id) {
        int fsdDel=this.safeFSDService.deleteBySubjectId(id);
        int designDel=this.safeDesignService.deleteBySubjectId(id);
        int comissinDel=this.safeCommissioningService.deleteBySubjectId(id);
        int accDel=this.safeAcceptanceService.deleteBySubjectId(id);
        int flag=this.safeMapper.deleteByPrimaryKey(id);
        if(flag>0){
            return 1;
        }else{
            return 0;
        }
    }

    @Override
    public int deleteByPrimaryKeyH(String id) {
        return this.safeMapper.deleteByPrimaryKeyH(id);
    }

    @Override
    public int deleteByPrimaryKeyF(String id) {
        return this.safeMapper.deleteByPrimaryKeyF(id);
    }

    @Override
    public int updateByPrimaryKeySelective(Map paramMap) {
        return this.safeMapper.updateByPrimaryKeySelective(paramMap);
    }
    @Override
    public int insertSelective(Map paramMap) {
        return this.safeMapper.insertSelective(paramMap);
    }

    @Override
    public int insertSelectiveH(Map paramMap) {
        return this.safeMapper.insertSelectiveH(paramMap);
    }

    @Override
    public int insertSelectiveF(Map paramMap) {
        return this.safeMapper.insertSelectiveF(paramMap);
    }

    @Override
    public Safe selectByProjectId(String id) {
        return this.safeMapper.selectByProjectId(id);
    }

    @Override
    public boolean exsitSafeSpecailty(String id) {
        Safe safe=this.safeMapper.selectByProjectId(id);
        return safe!=null;
    }

    @Override
    public boolean exsitSafeSpecailtyH(String id) {
        Safe safe=this.safeMapper.selectByProjectIdH(id);
        return safe!=null;
    }

    @Override
    public boolean exsitSafeSpecailtyF(String id) {
        Safe safe=this.safeMapper.selectByProjectIdF(id);
        return safe!=null;
    }

    @Override
    public List<Safe> selectByParam(Map paramMap) {
        return this.safeMapper.selectByParam( paramMap);
    }

    @Override
    public List<Safe> selectByParamH(Map paramMap) {
        return this.safeMapper.selectByParamH(paramMap);
    }

    @Override
    public List<Safe> selectByParamF(Map paramMap) {
        return this.safeMapper.selectByParamF(paramMap);
    }

    @Override
    public int selectCount(Map paramMap) {
        return this.safeMapper.selectCount(paramMap);
    }

    @Override
    public int selectCountH(Map paramMap) {
        return this.safeMapper.selectCountH(paramMap);
    }

    @Override
    public int selectCountF(Map paramMap) {
        return this.safeMapper.selectCountF(paramMap);
    }
}